package com.right.health.app.ui.me;

import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;

import com.magic.basic.activity.BaseActivity;
import com.right.health.app.R;

/*
 * Created by hopeliao on 2019-09-29
 *
 */
public class DataAuthorizationActivity extends BaseActivity implements View.OnClickListener {

    private CheckBox[] mCheckBoxGroup1 = new CheckBox[2];
    private TextView[] mTipsGroup1 = new TextView[2];

    private CheckBox[] mCheckBoxGroup2 = new CheckBox[4];
    private TextView[] mTipsGroup2 = new TextView[4];

    @Override
    public void onCreate(Bundle bundle, String s) {
        setContentView(R.layout.data_authorization);
    }


    @Override
    public void findView() {
        mCheckBoxGroup1[0] = (CheckBox) findViewById(R.id.cb_selected1);
        mCheckBoxGroup1[1] = (CheckBox) findViewById(R.id.cb_selected2);

        mTipsGroup1[0] = (TextView) findViewById(R.id.tv_tips1);
        mTipsGroup1[1] = (TextView) findViewById(R.id.tv_tips2);

        for (CheckBox cb : mCheckBoxGroup1) {
            cb.setOnClickListener(groupClick1);
        }

        mCheckBoxGroup2[0] = (CheckBox) findViewById(R.id.cb_selected3);
        mCheckBoxGroup2[1] = (CheckBox) findViewById(R.id.cb_selected4);
        mCheckBoxGroup2[2] = (CheckBox) findViewById(R.id.cb_selected5);
        mCheckBoxGroup2[3] = (CheckBox) findViewById(R.id.cb_selected6);

        for (CheckBox cb : mCheckBoxGroup2) {
            cb.setOnClickListener(groupClick2);
        }

        mTipsGroup2[0] = (TextView) findViewById(R.id.tv_tips3);
        mTipsGroup2[1] = (TextView) findViewById(R.id.tv_tips4);
        mTipsGroup2[2] = (TextView) findViewById(R.id.tv_tips5);
        mTipsGroup2[3] = (TextView) findViewById(R.id.tv_tips6);

    }

    private View.OnClickListener groupClick1 = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            for (int i = 0; i < mCheckBoxGroup1.length; i++) {
                if (v.getId() == mCheckBoxGroup1[i].getId()) {
                    if(mCheckBoxGroup1[i].isChecked()) {
                        mTipsGroup1[i].setTextColor(getResources().getColor(R.color.color_09C3BE));
                    } else {
                        mTipsGroup1[i].setTextColor(getResources().getColor(R.color.color_777777));
                    }
                } else {
                    mCheckBoxGroup1[i].setChecked(false);
                    mTipsGroup1[i].setTextColor(getResources().getColor(R.color.color_777777));
                }
            }
        }
    };

    private View.OnClickListener groupClick2 = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            for (int i = 0; i < mCheckBoxGroup2.length; i++) {
                if (v.getId() == mCheckBoxGroup2[i].getId()) {
                    if(mCheckBoxGroup2[i].isChecked()) {
                        mTipsGroup2[i].setTextColor(getResources().getColor(R.color.color_09C3BE));
                    } else {
                        mTipsGroup2[i].setTextColor(getResources().getColor(R.color.color_777777));
                    }
                } else {
                    mCheckBoxGroup2[i].setChecked(false);
                    mTipsGroup2[i].setTextColor(getResources().getColor(R.color.color_777777));
                }
            }
        }
    };

    @Override
    public void initialize() {

    }

    @Override
    public void onClick(View v) {



    }


}
